package com.wwwzh.himalayafm.fragment.down;


import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.wwwzh.himalayafm.activity.HotActivity;
import com.wwwzh.himalayafm.R;

/**
 * A simple {@link Fragment} subclass.
 */
public class PagerDownFragment extends Fragment implements View.OnClickListener {

    public static PagerDownFragment getInstance(String data) {
        PagerDownFragment fragment = new PagerDownFragment();
        Bundle bundle = new Bundle();
        bundle.putString("data", data);
        fragment.setArguments(bundle);
        return fragment;
    }


    public PagerDownFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_pager_down, container, false);
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        TextView text = (TextView) view.findViewById(R.id.tv_down);
        LinearLayout layout = (LinearLayout) view.findViewById(R.id.ll_pager_down);
        Button button = (Button) view.findViewById(R.id.down_btn);
        button.setOnClickListener(this);
        String data = getArguments().getString("data");
        switch (data) {
            case "专辑":
                layout.setBackgroundResource(R.drawable.no_downloaded);
                break;
            case "声音":
                layout.setBackgroundResource(R.drawable.no_downloaded);
                break;
            case "下载中":
                layout.setBackgroundResource(R.drawable.no_download);
                break;
        }

    }

    @Override
    public void onClick(View v) {
        Intent intent = new Intent(getActivity(), HotActivity.class);
        startActivity(intent);
    }
}
